<script setup>
import { RouterLink, RouterView } from 'vue-router'
import { onMounted } from 'vue'
import 'animate.css'

// 粒子背景效果
onMounted(() => {
  // 简化particles.js实现以避免错误
  try {
    if (typeof window.particlesJS !== 'undefined') {
      window.particlesJS('particles-js', {
        particles: {
          number: { value: 50 },
          color: { value: "#42b883" },
          shape: { type: "circle" },
          opacity: { value: 0.5 },
          size: { value: 3 },
          line_linked: { 
            enable: true, 
            distance: 150, 
            color: "#42b883", 
            opacity: 0.4 
          },
          move: { 
            enable: true, 
            speed: 1 
          }
        }
      })
    }
  } catch (e) {
    console.log("Particles.js not available, using fallback")
  }
})
</script>

<template>
  <div id="particles-js"></div>
  <div class="app-container">
    <nav class="top-nav">
      <RouterLink to="/" class="nav-link animated fadeInDown">Home</RouterLink>
      <RouterLink to="/tutorial" class="nav-link animated fadeInDown">Vue Tutorial</RouterLink>
    </nav>

    <main class="main-content animated fadeIn">
      <RouterView />
    </main>
  </div>
</template>

<style scoped>
#particles-js {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
}

.top-nav {
  background: rgba(255, 255, 255, 0.9);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(224, 224, 224, 0.5);
  display: flex;
  justify-content: center;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.nav-link {
  padding: 0.75rem 1.5rem;
  margin: 0 1rem;
  text-decoration: none;
  color: #2c3e50;
  border-radius: 50px;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}

.nav-link:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(66, 184, 131, 0.2), transparent);
  transition: 0.5s;
}

.nav-link:hover:before {
  left: 100%;
}

.nav-link:hover {
  background: linear-gradient(45deg, #42b883, #359c6d);
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(66, 184, 131, 0.4);
}

.nav-link.router-link-active {
  background: linear-gradient(45deg, #42b883, #359c6d);
  color: white;
  box-shadow: 0 5px 15px rgba(66, 184, 131, 0.4);
}

.main-content {
  flex: 1;
  padding: 0;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 1024px) {
  .top-nav {
    justify-content: center;
  }
}
</style>
